<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>所有品牌</title>
    <script src="js/axios-0.18.0.js"></script>
    <script src="js/vue.js"></script>
</head>
<body>

<div id="app">
    <a href="addBrand.html"><input type="button" value="新增"></a>
    <hr>
    <table id="brandTable" border="1" cellspacing="0" width="100%">
        <tr>
            <th>序号</th>
            <th>品牌名称</th>
            <th>企业名称</th>
            <th>排序</th>
            <th>品牌介绍</th>
            <th>状态</th>
            <th>操作</th>
        </tr>

        <!--使用v-for遍历对象数组-->
        <tr align="center" v-for="(brand, index) in brands">
            <td>{{index+1}}</td>
            <td>{{brand.brandName}}</td>
            <td>{{brand.companyName}}</td>
            <td>{{brand.ordered}}</td>
            <td>{{brand.description}}</td>
            <td>{{brand.status}}</td>
            <td><a href="#">修改</a> <a href="#">删除</a></td>
        </tr>
    </table>
</div>

<script>
    new Vue({
        el: "#app",
        data: {
            brands: []
        },
        mounted() {
            // alert("mounted: " + this);
            let _this = this;

            // Vue加载完成,发送AJAX请求到服务器获取数据
            axios.get("http://localhost:8080/vue-brand-demo/selectAllServlet")
                .then(function (resp) {
                    // console.log(resp.data);
                    // alert("then: " + _this);
                    _this.brands = resp.data;
                });
        }
    });
</script>
</body>
</html>